package mspbots.teams.client.core.data.users;

import com.fasterxml.jackson.databind.JsonNode;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * data.connector.teams.core.api.UsersController
 *
 * @author Alex bob(https://github.com/vnobo)
 * @date Created by 2020/4/15
 */
@Log4j2
@RestController
@RequiredArgsConstructor
@RequestMapping("users/{tenantId}")
public class UsersController {

    private final UsersServiceImpl usersService;

    @GetMapping("find")
    public Flux<JsonNode> find(@PathVariable Long tenantId) {
        return this.usersService.find(tenantId);
    }

    @GetMapping("manager/{userId}/find")
    public Mono<JsonNode> managers(@PathVariable Long tenantId,
                                   @PathVariable String userId) {
        return this.usersService.findManagers(tenantId, userId);
    }

    @GetMapping("manual-sync-photo")
    public Flux<JsonNode> manualSyncPhoto(@PathVariable Long tenantId) {
        return this.usersService.manualSyncPhoto(tenantId);
    }

    @GetMapping("joinedTeams/{id}")
    public Mono<JsonNode> joinedTeams(@PathVariable Long tenantId, @PathVariable String id) {
        return this.usersService.joinedTeams(tenantId, id);
    }
}
